/*
 * This code is property of CoreObjects. Use, duplication and disclosure
 * in any form without permission of copyright holder is prohibited.
 *
 */

package com.nen.session;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author amitm
 */
public class SessionMapItem implements Serializable{

    private String sessionId;
    private Map userInfoMap = new HashMap();

    private static final String[] FIELD_NAMES = {"userEmail",
                                                    "firstName",
                                                    "lastName",
                                                    "mobileNo",
                                                    "landLineNo"};

    public SessionMapItem(String sessionId, Object loginUserDetails) {
        this.sessionId = sessionId;
        populateUserInfoMap(loginUserDetails);
    }

    private void populateUserInfoMap(Object loginUserDetails) {
        for (int i = 0; i < FIELD_NAMES.length; i++) {
            String propName = FIELD_NAMES[i];
            Object value = NenUtils.getProperty(loginUserDetails, propName, "");
            userInfoMap.put(propName, value);
        }
    }
    
    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public Map getUserInfoMap() {
        return Collections.unmodifiableMap(userInfoMap);
    }

}
